/*
 * LDIR
 *
 * LDIR, a GPS cartography application built for Let's Do It Romania eco
 * campaign.
 * Copyright (C) 2010 Genera Software <office@generasoftware.com>
 *
 * http://generasoftware.com/
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place, Suite 330, Boston, MA 02111-1307 USA
 */
#ifndef WASTECACHE_H
#define WASTECACHE_H

// INCLUDES
#include <e32std.h>
#include <e32base.h>
#include "Interfaces.h"
#include "WsObject.h"

// CLASS DECLARATION

class CWasteInfo;

/**
 *  CWasteCache
 *
 */
class CWasteCache : public CWsObject, public MSerializable
	{
public:
	// Constructors and destructor

	/**
	 * Destructor.
	 */
	~CWasteCache();

	/**
	 * Two-phased constructor.
	 */
	static CWasteCache* NewL();

	/**
	 * Two-phased constructor.
	 */
	static CWasteCache* NewLC();

	// Takes ownership
	void AppendL( CWasteInfo* aWasteInfo );
	void ClearCache();
	void Remove( TInt aPos );
	void Remove( CWasteInfo* aWasteInfo );
	CWasteInfo* GetById( const TDesC& aWasteId );
	CWasteInfo* operator[]( const TInt aIndex ) const;

	TInt Count();

	void ExternalizeL( RWriteStream& aStream ) const;
	void InternalizeL( RReadStream& aStream );

	HBufC8* EncodeL( CJsonGenerator& aJsonGenerator );
	void DecodeL( const TDesC8& aDesC, CJsonParser& aJsonParser );

private:

	/**
	 * Constructor for performing 1st stage construction
	 */
	CWasteCache();

	/**
	 * EPOC default constructor for performing 2nd stage construction
	 */
	void ConstructL();

private:
	RPointerArray<CWasteInfo> iWasteCache;
	};

#endif // WASTECACHE_H
